﻿#define  _CRT_SECURE_NO_WARNINGS 1

#include "Vector.h"
#include<list>
#include <vector>
namespace xw
{
	void test_vector1()
	{
		vector<int> v1;
		vector<int> v2(5, 9);
		vector<int> v4(1, 5);
		for (int i = 0; i < v2.size(); ++i)
		{
			cout << v2[i] << " ";
		}
		cout << endl;

		vector<int> v3(v2);
		for (int i = 0; i < v3.size(); ++i)
		{
			cout << v3[i] << " ";
		}
		cout << endl;

		v3 = v4;
		for (int i = 0; i < v3.size(); ++i)
		{
			cout << v3[i] << " ";
		}
		cout << endl;
	}

	void test_vector2()
	{
		vector<int> v1;
		v1.push_back(5);
		v1.push_back(5);
		v1.push_back(5);
		v1.push_back(5);
		v1.push_back(5);
		v1.push_back(3);
		v1.pop_back();
		v1.pop_back();

		for (int i = 0; i < v1.size(); ++i)
		{
			cout << v1[i] << " ";
		}
		cout << endl;

	}

	void test_vector3()
	{
		vector<int> v1;
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);
		v1.push_back(5);
		v1.push_back(6);

		const vector<int> v2(v1);

		vector<int>::const_iterator cit1 = v2.cbegin();
		while (cit1 != v2.cend())
		{
			//*cit1 += 3;
			cout << *cit1 << " ";

			++cit1;
		}
		cout << endl;

		vector<int>::const_iterator cit = v1.cbegin();
		while (cit != v1.cend())
		{
			cout << *cit << " ";
			++cit;
		}



		/*for (auto e : v1)
		{
			cout << e << " ";
		}
		cout << endl;*/
	}

	void test_vector4()
	{
		vector<int> v1;
		v1.push_back(3);
		v1.push_back(4);
		v1.push_back(5);
		v1.push_back(6);

		v1.resize(8, 9);

		for (auto& e : v1)
		{
			cout << e << " ";
		}
		cout << v1.size() << endl;
		cout << v1.capacity() << endl;
		cout << endl;
	}

	void test_vector5()
	{
		list<int> lt1;
		lt1.push_back(1);
		lt1.push_back(2);
		lt1.push_back(3);
		lt1.push_back(4);

		vector<int> v1(lt1.begin(), lt1.end());

		vector<int>::iterator it = v1.begin();
		while (it != v1.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}

	void test_vector6()
	{
		/*vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);
		v1.insert(v1.begin(), 0);
		vector<int>::iterator it = v1.begin();
		while (it != v1.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;*/

		vector<int> v2;
		v2.insert(v2.begin(), 1);
		v2.insert(v2.begin(), 2);
		v2.push_back(3);
		v2.push_back(4);
		v2.erase(v2.begin());

		v2.pop_back();
		v2.pop_back();
		for (auto e : v2)
		{
			cout << e << " ";
		}
		cout << endl;
	}
	
}



int main()
{

	int ar[] = { 1,2,3,4,0,5,6,7,8,9 };

	int n = sizeof(ar) / sizeof(int);

	vector<int> v(ar, ar + n);

	vector<int>::iterator it = v.begin();

	while (it != v.end())

	{

		if (*it != 0)

			cout << *it;

		else

			v.erase(it);

		it++;

	}

	return 0;

}
//int main()
//{
//	xw::test_vector6();
//
//	/*int ar[] = { 0,1, 2, 3, 4,  5, 6, 7, 8, 9 };
//	int n = sizeof(ar) / sizeof(int);
//	list<int> mylist(ar, ar + n);
//	list<int>::iterator pos = find(mylist.begin(), mylist.end(), 5);
//	reverse(mylist.begin(), pos);
//	reverse(pos, mylist.end());
//	list<int>::const_reverse_iterator crit = mylist.crbegin();
//	while (crit != mylist.crend())
//	{
//		cout << *crit << " ";
//		++crit;
//	}
//	cout << endl;*/
//
//}